﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Management.master" AutoEventWireup="true"
    CodeFile="agent-commission.aspx.cs" Inherits="telereport_agent_commission" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="includes/GridStyleSheet.css" rel="stylesheet" type="text/css" />
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td>
                    <h1>
                        <asp:HyperLink ID="hplBacktoMenu" runat="server" NavigateUrl="~/ManagementHome.aspx">
                            <asp:Image runat="server" ID="imgBacktoMenu" ToolTip="Back To Menu" ImageUrl="~/images/buttons/back-to-menu.png"
                                AlternateText="Back To Menu" />
                        </asp:HyperLink>
                        Agent Commission Reports
                    </h1>
                </td>
            </tr>
            <tr id="trSearch" runat="server">
                <td>
                    <b>Campaign</b> :
                    <asp:DropDownList ID="ddlCampaign" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCampaign_SelectedIndexChanged">
                        <asp:ListItem Value="400">On-line</asp:ListItem>
                        <%--<asp:ListItem Value="1001">Off-line</asp:ListItem>--%>
                    </asp:DropDownList>
                    &nbsp;<b>App Type</b> :
                    <asp:DropDownList ID="ddlAppType" runat="server">
                        <%--<asp:ListItem Value="0">All</asp:ListItem>--%>
                        <asp:ListItem Value="1" Selected="True">New</asp:ListItem>
                        <asp:ListItem Value="2">Renew</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;<b>Report Type</b> :
                    <asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged">
                        <asp:ListItem Value="0" Selected="True">Monthly</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp; <b>
                        <asp:Label ID="lblFromDate" runat="server"></asp:Label></b>
                    <asp:DropDownList ID="ddlDay1" runat="server" ToolTip="Choose Day">
                        <asp:ListItem Value="01">01</asp:ListItem>
                        <asp:ListItem Value="02">02</asp:ListItem>
                        <asp:ListItem Value="03">03</asp:ListItem>
                        <asp:ListItem Value="04">04</asp:ListItem>
                        <asp:ListItem Value="05">05</asp:ListItem>
                        <asp:ListItem Value="06">06</asp:ListItem>
                        <asp:ListItem Value="07">07</asp:ListItem>
                        <asp:ListItem Value="08">08</asp:ListItem>
                        <asp:ListItem Value="09">09</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="11">11</asp:ListItem>
                        <asp:ListItem Value="12">12</asp:ListItem>
                        <asp:ListItem Value="13">13</asp:ListItem>
                        <asp:ListItem Value="14">14</asp:ListItem>
                        <asp:ListItem Value="15">15</asp:ListItem>
                        <asp:ListItem Value="16">16</asp:ListItem>
                        <asp:ListItem Value="17">17</asp:ListItem>
                        <asp:ListItem Value="18">18</asp:ListItem>
                        <asp:ListItem Value="19">19</asp:ListItem>
                        <asp:ListItem Value="20">20</asp:ListItem>
                        <asp:ListItem Value="21">21</asp:ListItem>
                        <asp:ListItem Value="22">22</asp:ListItem>
                        <asp:ListItem Value="23">23</asp:ListItem>
                        <asp:ListItem Value="24">24</asp:ListItem>
                        <asp:ListItem Value="25">25</asp:ListItem>
                        <asp:ListItem Value="26">26</asp:ListItem>
                        <asp:ListItem Value="27">27</asp:ListItem>
                        <asp:ListItem Value="28">28</asp:ListItem>
                        <asp:ListItem Value="29">29</asp:ListItem>
                        <asp:ListItem Value="30">30</asp:ListItem>
                        <asp:ListItem Value="31">31</asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddlMonth1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMonth1_SelectedIndexChanged">
                        <asp:ListItem Value="01">Jan</asp:ListItem>
                        <asp:ListItem Value="02">Feb</asp:ListItem>
                        <asp:ListItem Value="03">Mar</asp:ListItem>
                        <asp:ListItem Value="04">Apr</asp:ListItem>
                        <asp:ListItem Value="05">May</asp:ListItem>
                        <asp:ListItem Value="06">Jun</asp:ListItem>
                        <asp:ListItem Value="07">Jul</asp:ListItem>
                        <asp:ListItem Value="08">Aug</asp:ListItem>
                        <asp:ListItem Value="09">Sep</asp:ListItem>
                        <asp:ListItem Value="10">Oct</asp:ListItem>
                        <asp:ListItem Value="11">Nov</asp:ListItem>
                        <asp:ListItem Value="12">Dec</asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddlYear1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlYear1_SelectedIndexChanged">
                        <asp:ListItem Value="2010">2010</asp:ListItem>
                        <asp:ListItem Value="2011">2011</asp:ListItem>
                        <asp:ListItem Value="2012">2012</asp:ListItem>
                        <asp:ListItem Value="2013">2013</asp:ListItem>
                    </asp:DropDownList>
                    <b>
                        <asp:Label ID="lblToDate" runat="server"></asp:Label></b>
                    <asp:DropDownList ID="ddlDay2" runat="server" ToolTip="Choose Day">
                        <asp:ListItem Value="01">01</asp:ListItem>
                        <asp:ListItem Value="02">02</asp:ListItem>
                        <asp:ListItem Value="03">03</asp:ListItem>
                        <asp:ListItem Value="04">04</asp:ListItem>
                        <asp:ListItem Value="05">05</asp:ListItem>
                        <asp:ListItem Value="06">06</asp:ListItem>
                        <asp:ListItem Value="07">07</asp:ListItem>
                        <asp:ListItem Value="08">08</asp:ListItem>
                        <asp:ListItem Value="09">09</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="11">11</asp:ListItem>
                        <asp:ListItem Value="12">12</asp:ListItem>
                        <asp:ListItem Value="13">13</asp:ListItem>
                        <asp:ListItem Value="14">14</asp:ListItem>
                        <asp:ListItem Value="15">15</asp:ListItem>
                        <asp:ListItem Value="16">16</asp:ListItem>
                        <asp:ListItem Value="17">17</asp:ListItem>
                        <asp:ListItem Value="18">18</asp:ListItem>
                        <asp:ListItem Value="19">19</asp:ListItem>
                        <asp:ListItem Value="20">20</asp:ListItem>
                        <asp:ListItem Value="21">21</asp:ListItem>
                        <asp:ListItem Value="22">22</asp:ListItem>
                        <asp:ListItem Value="23">23</asp:ListItem>
                        <asp:ListItem Value="24">24</asp:ListItem>
                        <asp:ListItem Value="25">25</asp:ListItem>
                        <asp:ListItem Value="26">26</asp:ListItem>
                        <asp:ListItem Value="27">27</asp:ListItem>
                        <asp:ListItem Value="28">28</asp:ListItem>
                        <asp:ListItem Value="29">29</asp:ListItem>
                        <asp:ListItem Value="30">30</asp:ListItem>
                        <asp:ListItem Value="31">31</asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddlMonth2" runat="server">
                        <asp:ListItem Value="01">Jan</asp:ListItem>
                        <asp:ListItem Value="02">Feb</asp:ListItem>
                        <asp:ListItem Value="03">Mar</asp:ListItem>
                        <asp:ListItem Value="04">Apr</asp:ListItem>
                        <asp:ListItem Value="05">May</asp:ListItem>
                        <asp:ListItem Value="06">Jun</asp:ListItem>
                        <asp:ListItem Value="07">Jul</asp:ListItem>
                        <asp:ListItem Value="08">Aug</asp:ListItem>
                        <asp:ListItem Value="09">Sep</asp:ListItem>
                        <asp:ListItem Value="10">Oct</asp:ListItem>
                        <asp:ListItem Value="11">Nov</asp:ListItem>
                        <asp:ListItem Value="12">Dec</asp:ListItem>
                    </asp:DropDownList>
                    <asp:DropDownList ID="ddlYear2" runat="server">
                        <asp:ListItem Value="2010">2010</asp:ListItem>
                        <asp:ListItem Value="2011">2011</asp:ListItem>
                        <asp:ListItem Value="2012">2012</asp:ListItem>
                        <asp:ListItem Value="2013">2013</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp; <b>Agent</b> :
                    <asp:DropDownList ID="ddlAgentList" runat="server">
                    </asp:DropDownList>
                    &nbsp;<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />&nbsp;
                    <asp:DropDownList ID="ddlLanguage" runat="server" Visible="false">
                        <asp:ListItem Value="1">Thai</asp:ListItem>
                        <asp:ListItem Value="2">English</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;
                    <asp:Button ID="btnDownLoad" runat="server" Visible="false" Text="Generate Excel"
                        OnClick="btnDownLoad_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblRecordCount" runat="server"></asp:Label>
                    <div style="display: none">
                        <asp:TextBox ID="txtReportType" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate1" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate2" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtReportDate" runat="server"></asp:TextBox>
                        <asp:TextBox runat="server" ReadOnly="true" ID="txtAgentId"></asp:TextBox>
                        <asp:Label ID="lblContent" runat="server"></asp:Label>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
                    <asp:GridView ID="grvIndAgentCommisionSummary" runat="server" AutoGenerateColumns="False"
                        CellSpacing="3" CellPadding="3" Width="100%" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                        EmptyDataText="There are no data records to display." GridLines="None" OnRowDataBound="grvIndAgentCommisionSummary_RowDataBound">
                        <Columns>
                            <asp:BoundField DataField="OrderDate" HeaderText="OrderDate" SortExpression="OrderDate" />
                            <asp:BoundField DataField="TypeOfLeads" HeaderText="TypeOfLeads" SortExpression="TypeOfLeads" />
                            <asp:BoundField DataField="AgentName" HeaderText="AgentName" SortExpression="AgentName" />
                            <asp:BoundField DataField="ApplicationName" HeaderText="ApplicationName" SortExpression="ApplicationName" />
                            <asp:BoundField DataField="Insurer" HeaderText="Insurer" SortExpression="Insurer" />
                            <asp:BoundField DataField="InsuranceType" HeaderText="InsuranceType" SortExpression="InsuranceType" />
                            <asp:BoundField DataField="CarPlate" HeaderText="CarPlate" SortExpression="CarPlate" />
                            <asp:BoundField DataField="QuoteRefNo" HeaderText="QuoteRefNo" SortExpression="QuoteRefNo" />
                            <asp:BoundField DataField="VMI" HeaderText="VMI" SortExpression="VMI" DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CMI" HeaderText="RptCMI" SortExpression="CMI" DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CollectedAmount" HeaderText="Collected Amount" SortExpression="CollectedAmount"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="TotalAmount" HeaderText="TotalAmount" SortExpression="TotalAmount"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CommissionPer" HeaderText="Com (%)" SortExpression="CommissionPer"
                                DataFormatString="{0:#0.0}%" />
                            <asp:BoundField DataField="Commission" HeaderText="Commission" SortExpression="Commission"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="Incentive" HeaderText="Incentive" SortExpression="Incentive"
                                DataFormatString="{0:#,0.00}" />
                            <%--<asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total"
                                DataFormatString="{0:#,0.00}" />--%>
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:GridView ID="grvAgentCommisionSummary" runat="server" AutoGenerateColumns="False"
                        CellSpacing="3" CellPadding="3" Width="100%" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                        EmptyDataText="There are no data records to display." GridLines="None" OnRowDataBound="grvAgentCommisionSummary_RowDataBound">
                        <Columns>
                            <asp:BoundField DataField="ApplicationType" HeaderText="ApplicationType" SortExpression="ApplicationType" />
                            <asp:BoundField DataField="BrokerName" HeaderText="Broker" SortExpression="BrokerName" />
                            <asp:BoundField DataField="AgentNameEN" HeaderText="AgentName" SortExpression="AgentNameEN" />
                            <asp:BoundField DataField="VMI" HeaderText="VMI" SortExpression="VMI" DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CMI" HeaderText="RptCMI" SortExpression="CMI" DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CollectedAmount" HeaderText="Collected Amount" SortExpression="CollectedAmount"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="CommissionPer" HeaderText="Com (%)" SortExpression="CommissionPer"
                                DataFormatString="{0:#0.0}" />
                            <asp:BoundField DataField="Commission" HeaderText="Commission" SortExpression="Commission"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="Incentive" HeaderText="Incentive" SortExpression="Incentive"
                                DataFormatString="{0:#,0.00}" />
                            <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total"
                                DataFormatString="{0:#,0.00}" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:GridView ID="grvCommisionSummary" runat="server" AutoGenerateColumns="False"
                        CellSpacing="3" CellPadding="3" Width="100%" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                        EmptyDataText="There are no data records to display." GridLines="None" OnRowDataBound="grvCommisionSummary_RowDataBound">
                        <Columns>
                            <asp:BoundField DataField="ApplicationDate" HeaderText="Date" SortExpression="ApplicationDate"
                                DataFormatString="{0:dd/MM/yyyy hh:mm tt}" />
                            <asp:BoundField DataField="QuoteRefNo" HeaderText="Reference No." SortExpression="QuoteRefNo" />
                            <asp:BoundField DataField="AgentName" HeaderText="Broker" SortExpression="AgentName" />
                            <asp:BoundField DataField="CustomerName" HeaderText="Customer Name" SortExpression="CustomerName" />
                            <asp:BoundField DataField="CompanyName" HeaderText="Insurance Company" SortExpression="CompanyName" />
                            <asp:BoundField DataField="InsuranceType" HeaderText="Insurance Type" SortExpression="InsuranceType" />
                            <asp:BoundField DataField="VMI" HeaderText="VMI" SortExpression="VMI" DataFormatString="฿{0:#,0.00}" />
                            <asp:BoundField DataField="CMI" HeaderText="RptCMI" SortExpression="CMI" DataFormatString="฿{0:#,0.00}" />
                            <asp:BoundField DataField="TotalPremium" HeaderText="Total Premium" SortExpression="TotalPremium"
                                DataFormatString="฿{0:#,0.00}" />
                            <asp:BoundField DataField="CollectedAmount" HeaderText="Collected Amount" SortExpression="CollectedAmount"
                                DataFormatString="฿{0:#,0.00}" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <div style="width:100%; overflow:auto; height:auto;">
                    <div id="grdCharges" runat="server" style="width:125%; height:auto">
                        <asp:GridView ID="grvAllCommisionSummary" runat="server" AutoGenerateColumns="False"
                            CellSpacing="3" CellPadding="3" CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"
                            EmptyDataText="There are no data records to display." GridLines="None" OnRowDataBound="grvAllCommisionSummary_RowDataBound">
                            <Columns>
                                <asp:BoundField DataField="Agent" HeaderText="Broker" SortExpression="Agent" ItemStyle-Width="200px" />
                                <asp:BoundField DataField="AZCP" HeaderText="Allianz CP" SortExpression="AZCP" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="AXA" HeaderText="AXA" SortExpression="AXA" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="BKI" HeaderText="BKI" SortExpression="BKI" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="CTS" HeaderText="Chartis" SortExpression="CTS" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="KPI" HeaderText="KrungThai" SortExpression="KPI" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="KSK" HeaderText="KSK" SortExpression="KSK" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="LMG" HeaderText="LMG" SortExpression="LMG" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="MIR" HeaderText="Mittare" SortExpression="MIR" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="MSIG" HeaderText="MSIG" SortExpression="MSIG" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="MTI" HeaderText="MuangThai" SortExpression="MTI" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="SCSMG" HeaderText="SCSMG" SortExpression="SCSMG" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="SMK" HeaderText="Syn Mun Kong" SortExpression="SMK" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="TVV" HeaderText="Thaivivat" SortExpression="TVV" ItemStyle-Width="100px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="TMS" HeaderText="Tokio Marine" SortExpression="TMS" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="VRY" HeaderText="Viriyah" SortExpression="VRY" ItemStyle-Width="110px"
                                    DataFormatString="{0:#,0.00}" />
                                <asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" ItemStyle-Width="110px"
                                    ItemStyle-Font-Bold="true" DataFormatString="{0:#,0.00}" />
                            </Columns>
                            <FooterStyle />
                            <PagerStyle />
                            <SelectedRowStyle />
                            <HeaderStyle CssClass="admin_gridheader" />
                            <EditRowStyle />
                            <AlternatingRowStyle CssClass="admin_gridodd" />
                            <RowStyle CssClass="admin_grideven" />
                        </asp:GridView>
                    </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblCommissionTable" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
